[id].vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <div class="topBg">
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <!-- 页面导航 -->
  6. <HomePageNavigation></HomePageNavigation>
  7. </div>
  8. <!-- 面包屑导航 -->
  9. <div class="breadcrumb">
  10. <div class="inner">
  11. <span class="location">当前位置:</span>
  12. <el-breadcrumb :separator-icon="ArrowRight">
  13. <el-breadcrumb-item>
  14. <NuxtLink to="/">首页</NuxtLink>
  15. </el-breadcrumb-item>
  16. <el-breadcrumb-item v-if="parent_children_count > 0">
  17. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  18. </el-breadcrumb-item>
  19. <el-breadcrumb-item v-if="parent_children_count == 0">
  20. <NuxtLink :to="`/${parent_pinyin}/list-1.html`"> {{ parent_name }}</NuxtLink>
  21. </el-breadcrumb-item>
  22. <el-breadcrumb-item class="phone_breadcrumb_text" v-if="!routeNewsTtitle">
  23. {{ routeNewsTtitle }}
  24. </el-breadcrumb-item>
  25. </el-breadcrumb>
  26. </div>
  27. </div>
  28. <!-- 资讯列表 -->
  29. <div class="newsDetail">
  30. <div class="inner">
  31. <div class="innerLeft">
  32. <div class="LeftTop">
  33. <h1>{{ newsDetail.title }}</h1>
  34. <p class="phone_none">
  35. 发布时间: <span>{{ time }}</span>
  36. 来源: <span>{{ newsDetail.copyfrom }}</span>
  37. 作者: <span>{{ newsDetail.author }}</span>
  38. </p>
  39. </div>
  40. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  41. </div>
  42. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  43. <img :src="selectedImage" alt="Preview">
  44. </div>
  45. <!-- 免责声明: -->
  46. <div class="disclaimer" v-if="newsDetail.copyfrom != '本网'">
  47. <p>原文链接:{{ newsDetail.fromurl }}</p>
  48. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  49. </div>
  50. <!-- 投票 start ---------------------------------------->
  51. <!-- <div v-if="articleChoice">
  52. <div class="index_3_box_vote" v-if="articleChoice">
  53. <div class="voteTitle">投票区</div>
  54. <div class="inquire">
  55. <p v-if="voteList.length > 0">{{ voteList[0].survey_name }}</p>
  56. <div class="radioBox">
  57. 投票选项
  58. <div v-if="!isDisabled">
  59. <div class="radio" v-if="isRadio">
  60. <el-radio-group v-model="radio1" @change="handleRadioChange">
  61. <el-radio v-for="item in voteList" :key="item.id" :value="item.id"
  62. size="large">
  63. <span v-if="item.is_other == 0">{{ item.choice_name }}</span>
  64. <span v-else>其他</span>
  65. </el-radio>
  66. </el-radio-group>
  67. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  68. resize="none" placeholder="请输入.." />
  69. </div>
  70. <div class="checkInputBox" v-else>
  71. <el-checkbox-group v-model="check1" @change="handleCheckboxChange">
  72. <span v-for="item in voteList" :key="item.id">
  73. <span v-if="item.is_other == 0">
  74. <el-checkbox size="large" :label="item.choice_name"
  75. :value="item.id" />
  76. </span>
  77. <span v-else>
  78. <el-checkbox size="large" label="其他" :value="item.id" />
  79. </span>
  80. </span>
  81. </el-checkbox-group>
  82. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  83. resize="none" placeholder="请输入.." />
  84. </div>
  85. </div>
  86. 投票结果
  87. <div class="inquireData" v-else>
  88. <div v-for="item in websiteSurveyData.data" :key="item.id">
  89. <div class="inquireDataItem active" v-if="item.status == 1">
  90. <div class="inquireDataItemTitle">
  91. <span v-if="item.choice_name == ''">其他</span>
  92. <span v-else>{{ item.choice_name }}</span>
  93. </div>
  94. <div class="inquireDataItemNum">{{ item.results }}票</div>
  95. </div>
  96. <div class="inquireDataItem" v-else>
  97. <div class="inquireDataItemTitle">
  98. <span v-if="item.choice_name == ''">其他</span>
  99. <span v-else>{{ item.choice_name }}</span>
  100. </div>
  101. <div class="inquireDataItemNum">{{ item.results }}票</div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="btn">
  107. <button class="voting" @click="addWebsiteSurvey" :disabled="isDisabled"
  108. v-if="!isDisabled">投票</button>
  109. </div>
  110. </div>
  111. </div>
  112. </div> -->
  113. <!-- 投票 end ---------------------------------------->
  114. <!-- <div class="recommendRead" v-if="newsDetail.commendArticle != false">
  115. <div class="recommendReadTitle">
  116. <span class="read_title">
  117. 推荐阅读
  118. </span>
  119. </div>
  120. <div class="recommendReadList">
  121. <div class="recommendReadListTitle" v-for="(item, index) in newsDetail.commendArticle"
  122. :key="item.id">
  123. <a :href="`/${item.alias_pinyin}/${item.id}.html`" v-if="index < 3">
  124. {{ item.title }}
  125. </a>
  126. </div>
  127. </div>
  128. </div> -->
  129. </div>
  130. <div class="innerRight">
  131. <!-- 热点资讯1 -->
  132. <div class="hotList1">
  133. <DetailHotNews></DetailHotNews>
  134. </div>
  135. <!-- 热点资讯2 -->
  136. <!-- <div class="hotList2">
  137. <DetailHotNews2></DetailHotNews2>
  138. </div> -->
  139. </div>
  140. </div>
  141. </div>
  142. <!-- 页面底部 -->
  143. <HomeFoot></HomeFoot>
  144. </template>
  145. <script setup>
  146. //1.页面依赖 start ---------------------------------------->
  147. import { onMounted } from 'vue'
  148. import { ElBreadcrumb, ElBreadcrumbItem, ElRadio, ElRadioGroup, ElCheckbox, ElCheckboxGroup, ElMessage, ElInput } from 'element-plus'
  149. import { ArrowRight } from '@element-plus/icons-vue'
  150. const nuxtApp = useNuxtApp();
  151. const axios = nuxtApp.$axios;
  152. //1.1 获得跳转过来的id
  153. const route = useRoute();
  154. //获得详情id
  155. const articleId = parseInt(route.params.id); //获得该页面的id
  156. //获得当前的完整路径
  157. const fullPath = route.path;
  158. //拆分,取出来中间这一段,然后提取数字部分
  159. const segments = fullPath.split('/');
  160. const targetSegment = segments[1];
  161. // const numberPart = targetSegment.match(/\d+$/)?.[0];
  162. // let routeId = 20 //排除路径错误可以打开这个
  163. // const routeId = numberPart;
  164. let routeId;
  165. //通过导航路径反向查询导航id
  166. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  167. method: 'GET',
  168. query: {
  169. 'pinyin': targetSegment,
  170. },
  171. });
  172. if (getRouteId.code == 200) {
  173. routeId = getRouteId.data.category_id
  174. } else {
  175. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  176. console.log("错误位置:通过url路径查询导航池id")
  177. console.log("后端错误反馈:", getRouteId.message)
  178. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  179. }
  180. //1.2 获得父级栏目的名称、id
  181. const parent_name = ref([]);
  182. const parent_id = ref([]);
  183. const parent_pinyin = ref("");
  184. const parent_children_count = ref(0)
  185. let getParentNav = async () => {
  186. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  187. method: 'GET',
  188. query: {
  189. 'catid': routeId
  190. },
  191. });
  192. console.log("获取父级栏目数据")
  193. console.log(listData)
  194. if (listData.code == 200) {
  195. console.log(listData.data);
  196. parent_name.value = listData.data.alias;
  197. parent_id.value = listData.data.parent_id;
  198. parent_pinyin.value = listData.data.aLIas_pinyin;
  199. parent_children_count.value = listData.data.children_count;
  200. } else {
  201. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  202. console.log("错误位置:获取面包屑导航")
  203. console.log("后端错误反馈:", listData.message)
  204. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  205. }
  206. }
  207. //获得父级栏目详情
  208. getParentNav();
  209. //1.页面依赖 end ---------------------------------------->
  210. //2.页面数据 start ---------------------------------------->
  211. //2.1 资讯详情
  212. const newsDetail = ref({})
  213. const routeNewsTtitle = ref("");
  214. //2.2 发布日期
  215. const time = ref("");
  216. //2.3 路径
  217. const routLevelTitle = ref("");
  218. const routLevelId = ref("");
  219. //是否展示投票
  220. const articleChoice = ref(false);
  221. //2.4获取详情
  222. async function getPageData() {
  223. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  224. method: 'GET',
  225. query: {
  226. 'articleid': articleId
  227. },
  228. });
  229. if (mkdata.code == 200) {
  230. console.log('资讯详情1111', mkdata.data)
  231. //判断是否显示投票
  232. if (mkdata.data.is_survey == 1) {
  233. console.log("本篇文章含有投票!")
  234. articleChoice.value = true;
  235. getVoteList();
  236. }
  237. //获取内容
  238. newsDetail.value = mkdata.data;
  239. //获取路径
  240. // routLevelTitle.value = newsDetail.value.cat_name;
  241. // routLevelId.value = newsDetail.value.category_id;
  242. //获取发布时间
  243. // time.value = newsDetail.value.updated_at.split(' ')[0];
  244. //修正标题长度
  245. if (newsDetail.value.title.length >= 30) {
  246. routeNewsTtitle.value = newsDetail.value.title.substr(0, 30) + "...";
  247. } else {
  248. routeNewsTtitle.value = newsDetail.value.title
  249. }
  250. } else {
  251. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  252. console.log("错误位置:获取详情内容")
  253. console.log("后端错误反馈:", mkdata.message)
  254. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  255. }
  256. }
  257. getPageData();
  258. //2.5 获得广告
  259. //广告列表
  260. let adImg1 = ref([]);
  261. // async function getAdData(){
  262. // const adData = await requestDataPromise('/web/getWebsiteAdvertisement',{method:'GET',query:{'ad_tag':'DETAIL'}});
  263. // if(adData.code==200){
  264. // for(let item of adData.data){
  265. // if(item.ad_tag == 'DETAIL_0001'){
  266. // adImg1.value = item;
  267. // }
  268. // }
  269. // }else{
  270. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  271. // console.log("错误位置:获取详情页广告列表")
  272. // console.log("后端错误反馈:",adData.message)
  273. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  274. // }
  275. // }
  276. // getAdData();
  277. onMounted(async () => {
  278. const { $webUrl, $CwebUrl } = useNuxtApp();
  279. //广告1
  280. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_detail_0001`
  281. const responseAd1 = await fetch(url, {
  282. headers: {
  283. 'Content-Type': 'application/json',
  284. 'Userurl': $CwebUrl,
  285. 'Origin': $CwebUrl
  286. }
  287. });
  288. const resultAd1 = await responseAd1.json();
  289. adImg1.value = resultAd1.data[0];
  290. })
  291. //2.页面数据 end ---------------------------------------->
  292. //3.设置seo信息 start---------------------------------------->
  293. //3.1 设置seo信息
  294. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  295. method: 'GET',
  296. query: {
  297. 'articleid': articleId
  298. },
  299. });
  300. if (setData.code == 200) {
  301. let seoTitle = setData.data.title;
  302. let seoDescription = setData.data.introduce;
  303. let seoKeywords = setData.data.keyword;
  304. let seoSuffix = setData.data.suffix;
  305. let seoName = setData.data.website_name;
  306. useSeoMeta({
  307. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  308. meta: [
  309. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  310. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  311. ]
  312. });
  313. } else {
  314. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  315. console.log("错误位置:设置详情页面SEO数据")
  316. console.log("后端错误反馈:", setData.message)
  317. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  318. }
  319. //3.设置seo信息 end---------------------------------------->
  320. //4.投票 start---------------------------------------->
  321. const radio1 = ref(''); //单选
  322. const check1 = ref([]); //多选
  323. const isDisabled = ref(false);//是否禁用提交按钮
  324. const isRadio = ref(true);//是否渲染单选
  325. const userSurId = ref('');//投票属于哪一篇文章
  326. const userChoice = ref('');//用于判断用户选择了其他选项以后,输入的值
  327. const userIsChoice = ref('');//用于判断其他选项目前是什么值
  328. const showUserChoice = ref(false);//是否显示其他输入框
  329. const websiteSurveyData = ref([]);//投票结果
  330. //3.2获得投票列表
  331. let voteList = ref([]);
  332. async function getVoteList() {
  333. const voteData = await requestHome('/web/getWebsiteSurvey', { method: 'GET', query: { 'art_id': articleId } });
  334. console.log(778899)
  335. console.log(voteData)
  336. if (voteData.code == 200) {
  337. voteList.value = voteData.data;
  338. console.log(voteList.value)
  339. //判断显示单选还是多选
  340. //survey_type 0是单选 1是多选
  341. if (voteData.data[0].survey_type == 0) {
  342. isRadio.value = true;
  343. console.log("1111")
  344. } else {
  345. isRadio.value = false;
  346. }
  347. //把最后一个的值拿出来 用于判断用户是否选择了其他
  348. for (let item of voteData.data) {
  349. //如果含有其他
  350. if (item.is_other == 1) {
  351. userIsChoice.value = item.id;
  352. }
  353. }
  354. //用户投票属于哪一篇文章
  355. userSurId.value = voteData.data[0].sur_id;
  356. } else {
  357. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  358. console.log("错误位置:首页投票")
  359. console.log("后端错误反馈:", voteData.message)
  360. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  361. }
  362. }
  363. //3.2当用户选择了选项,判断是否展示其他输入框
  364. const handleRadioChange = (value) => {
  365. if (value == userIsChoice.value) {
  366. showUserChoice.value = true;
  367. } else {
  368. showUserChoice.value = false;
  369. }
  370. }
  371. const handleCheckboxChange = (value) => {
  372. if (value.includes(userIsChoice.value)) {
  373. showUserChoice.value = true;
  374. } else {
  375. showUserChoice.value = false;
  376. }
  377. }
  378. //3.2发起投票
  379. async function addWebsiteSurvey() {
  380. //判断当前是单选还是多选
  381. console.log(isRadio.value)
  382. if (isRadio.value) {
  383. console.log("用户单选!")
  384. if (radio1.value != '') {
  385. //先判断一下是否使用了其他选项
  386. if (showUserChoice.value) {
  387. if (userChoice.value != '') {
  388. //文章id
  389. // console.log(userSurId.value)
  390. // 用户输入的值
  391. // console.log(userChoice.value)
  392. //如果使用了其他,其他的选项需要增加进去
  393. const ChoiceData = await requestHome('/web/addWebsiteSurveyOption', {
  394. method: 'GET',
  395. query: {
  396. 'sur_id': userSurId.value,//投票的新闻id
  397. 'choice_name': userChoice.value,//投票的选项id
  398. }
  399. });
  400. if (ChoiceData.code == 200) {
  401. //提交完其他选项以后,再正式发起投票
  402. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  403. method: 'GET',
  404. query: {
  405. 'sur_id': userSurId.value,
  406. 'choice_id': ChoiceData.data
  407. }
  408. });
  409. if (mkData.code == 200) {
  410. ElMessage.success('投票成功!')
  411. //把投票结果显示到页面上 禁用投票按钮
  412. isDisabled.value = true;
  413. websiteSurveyData.value = mkData.data;
  414. //遍历一下,把用户选中的那个设置status为1
  415. let data = mkData.data;
  416. //遍历一下,把用户选中的那个设置status为1
  417. for (let item of data.data) {
  418. for (let i of data.choice) {
  419. if (item.id == i) {
  420. console.log(item.id)
  421. item.status = 1;
  422. }
  423. }
  424. }
  425. websiteSurveyData.value = data;
  426. } else {
  427. ElMessage.error(mkData.message)
  428. }
  429. } else {
  430. ElMessage.error('其他投票失败!')
  431. }
  432. } else {
  433. ElMessage.error('请输入选项内容!')
  434. }
  435. } else {
  436. //如果没选择其他,直接提交选择的内容
  437. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  438. method: 'GET',
  439. query: {
  440. 'sur_id': userSurId.value,
  441. 'choice_id': radio1.value
  442. }
  443. });
  444. if (mkData.code == 200) {
  445. ElMessage.success('投票成功!')
  446. //把投票结果显示到页面上 禁用投票按钮
  447. isDisabled.value = true;
  448. let data = mkData.data;
  449. //遍历一下,把用户选中的那个设置status为1
  450. for (let item of data.data) {
  451. for (let i of data.choice) {
  452. if (item.id == i) {
  453. item.status = 1;
  454. }
  455. }
  456. }
  457. websiteSurveyData.value = data;
  458. } else {
  459. ElMessage.error('投票失败!')
  460. }
  461. }
  462. } else {
  463. ElMessage.error('请选择一个选项')
  464. }
  465. } else {
  466. console.log("多选!")
  467. //多选
  468. if (check1.value != []) {
  469. //先判断一下是否使用了其他选项
  470. if (showUserChoice.value) {
  471. if (userChoice.value != '') {
  472. //判断用户是否只选择了一个其他
  473. if (check1.value.length == 1) {
  474. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  475. method: 'GET',
  476. query: {
  477. 'sur_id': userSurId.value,//投票的新闻id
  478. 'choice_name': userChoice.value,//用户输入的其他选项文字
  479. }
  480. });
  481. if (ChoiceData.code == 200) {
  482. //提交完其他选项以后,再正式发起投票
  483. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  484. method: 'GET',
  485. query: {
  486. 'sur_id': userSurId.value,
  487. 'choice_id': ChoiceData.data
  488. }
  489. });
  490. if (mkData.code == 200) {
  491. ElMessage.success('投票成功!')
  492. //把投票结果显示到页面上 禁用投票按钮
  493. isDisabled.value = true;
  494. websiteSurveyData.value = mkData.data;
  495. //遍历一下,把用户选中的那个设置status为1
  496. let data = mkData.data;
  497. //遍历一下,把用户选中的那个设置status为1
  498. for (let item of data.data) {
  499. for (let i of data.choice) {
  500. if (item.id == i) {
  501. console.log(item.id)
  502. item.status = 1;
  503. }
  504. }
  505. }
  506. websiteSurveyData.value = data;
  507. } else {
  508. ElMessage.error(mkData.message)
  509. }
  510. } else {
  511. ElMessage.error('其他投票失败!')
  512. }
  513. } else {
  514. //用户选择了除了其他以外,还包括别的选项
  515. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  516. method: 'GET',
  517. query: {
  518. 'sur_id': userSurId.value,//投票的新闻id
  519. 'choice_name': userChoice.value,//用户输入的其他选项文字
  520. }
  521. });
  522. if (ChoiceData.code == 200) {
  523. let data = check1.value;
  524. //找到多选的数组,把其他默认值给替换掉
  525. for (let i = 0; i < data.length; i++) {
  526. if (data[i] == userIsChoice.value) {
  527. data[i] = ChoiceData.data;
  528. }
  529. }
  530. let jsonArray = JSON.stringify(data);
  531. //提交完其他选项以后,再正式发起投票
  532. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  533. method: 'GET',
  534. query: {
  535. 'sur_id': userSurId.value,
  536. 'choice_id': jsonArray
  537. }
  538. });
  539. if (mkData.code == 200) {
  540. ElMessage.success('投票成功!')
  541. //把投票结果显示到页面上 禁用投票按钮
  542. isDisabled.value = true;
  543. websiteSurveyData.value = mkData.data;
  544. //遍历一下,把用户选中的那个设置status为1
  545. let data = mkData.data;
  546. //遍历一下,把用户选中的那个设置status为1
  547. for (let item of data.data) {
  548. for (let i of data.choice) {
  549. if (item.id == i) {
  550. //console.log(item.id)
  551. item.status = 1;
  552. }
  553. }
  554. }
  555. websiteSurveyData.value = data;
  556. } else {
  557. ElMessage.error(mkData.message)
  558. }
  559. } else {
  560. ElMessage.error('其他投票失败!')
  561. }
  562. }
  563. } else {
  564. ElMessage.error('请输入选项内容!')
  565. }
  566. } else {
  567. let jsonArray = JSON.stringify(check1.value);
  568. //如果没选择其他,直接提交选择的内容
  569. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  570. method: 'GET',
  571. query: {
  572. 'sur_id': userSurId.value,
  573. 'choice_id': jsonArray
  574. }
  575. });
  576. if (mkData.code == 200) {
  577. ElMessage.success('投票成功!')
  578. //把投票结果显示到页面上 禁用投票按钮
  579. isDisabled.value = true;
  580. websiteSurveyData.value = mkData.data;
  581. //遍历一下,把用户选中的那个设置status为1
  582. let data = mkData.data;
  583. //遍历一下,把用户选中的那个设置status为1
  584. for (let item of data.data) {
  585. for (let i of data.choice) {
  586. if (item.id == i) {
  587. console.log(item.id)
  588. item.status = 1;
  589. }
  590. }
  591. }
  592. websiteSurveyData.value = data;
  593. } else {
  594. ElMessage.error('投票失败!')
  595. }
  596. }
  597. } else {
  598. ElMessage.error('请选择一个选项')
  599. }
  600. }
  601. }
  602. //4.投票 end---------------------------------------->
  603. //5.页面图片放大 start---------------------------------------->
  604. const previewVisible = ref(false)
  605. const selectedImage = ref(' ')
  606. const openPreview = (event) => {
  607. if (event.target.tagName === 'IMG') {
  608. selectedImage.value = event.target.src;
  609. previewVisible.value = true;
  610. }
  611. }
  612. const closePreview = () => {
  613. previewVisible.value = false;
  614. }
  615. //5.页面图片放大 end---------------------------------------->
  616. </script>
  617. <style lang="less" scoped>
  618. @import url('@/assets/css/detail.less');
  619. </style>